package com.mrent.web.controller.admin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mrent.entity.OrderManager;
import com.mrent.service.OrderManagerService;
import com.mrent.service.Page;
import com.mrent.util.Constance;
import com.mrent.util.RenderUtil;


@Controller
public class AdminOrderManagerController {
	
	@Autowired
	private OrderManagerService orderManagerService;
	
	/**
	 * 店主管理.
	 * @return
	 */
	@RequestMapping("/admin/manager/index")
	public String home(){
		return "admin/manager/home";
	}
	
	/**
	 * 店主列表.
	 * 
	 * @param page
	 * @param response
	 * @return
	 */
	@RequestMapping("/admin/manager/list")
	public String list(String page,HttpServletResponse response){
		int p = 1;
		Page pp = new Page();
		try{
			p = Integer.parseInt(page);
		}catch(Exception e){
			p = 1;
		}
		pp.setPageNo(p);
		pp.setPageSize(Constance.DEFAULT_PAGE_SIZE);
		
		List<OrderManager> list = orderManagerService.listOrderManager(pp);
		
		Map<String,Object> json = new HashMap<String,Object>();
		json.put("rows", list);
		json.put("total", pp.getTotalCount());
		RenderUtil.renderJson(json,response);
		
		return null;
	}

}
